package com.md.client.helper;

import com.fasterxml.jackson.core.type.TypeReference;
import com.md.api.OpenLogsApi;
import com.md.base.BaseClient;
import com.md.model.system.BaseOpenController;
import com.md.model.system.CommonResult;
import com.md.request.OperationLogsRequest;
import com.md.response.LogsResponse;

/**
 * @author 刘骄阳
 * 2024-10-11 15:05
 */
public class DefaultOpenLogsController extends BaseOpenController implements OpenLogsApi {
  public DefaultOpenLogsController(final BaseClient baseClient, final String endpoint) {
    super(baseClient, endpoint, "logger-center", "/apps/logger" + PATH_PREFIX);
  }

  @Override
  public CommonResult<LogsResponse> create(final OperationLogsRequest request) {
    return checkResponse(getBaseClient().post(buildPostUrl("/create"), request,
      new TypeReference<CommonResult<LogsResponse>>() {
      }));
  }

  @Override
  public CommonResult<LogsResponse> update(final OperationLogsRequest request) {
    return checkResponse(getBaseClient().post(buildPostUrl("/update"), request,
      new TypeReference<CommonResult<LogsResponse>>() {
      }));
  }
}
